<?php

namespace App\Models\Scopes;

use App\Models\BaseModel;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Scope;

class VirtualNo implements Scope
{
    public function apply(Builder $builder, Model $model)
    {
        $table = $model->getTable();
        $dictionary = config('dictionary');
        if(isset($dictionary[$table])){
            $columns = array_keys($dictionary[$table]);
            if (in_array('is_virtual', $columns)) {
                $builder->where($table.'.is_virtual', 0);
            }
        }
    }
}
